const app = getApp();
Component({
  //数据
  data: {
    selected: 0,//当前tabBar页面
    color: "#7A7E83",//未选中tabBar时的文字颜色
    selectedColor: "#C40002",//选中时tabBar文字颜色
    // tabBar对象集合
    list: [
      {
        pagePath: "/pages/home/home",
        iconPath: "/pages/pageImages/new/tab1.png",
        selectedIconPath: "/pages/pageImages/new/tabSelect1.png",
        text: "首页"
      },
      {
        pagePath: "/pages/learn/learn",
        iconPath: "/pages/pageImages/new/tab2.png",
        selectedIconPath: "/pages/pageImages/new/tabSelect2.png",
        text: "学习"
      },
      {
        pagePath: "/pages/org/org",
        iconPath: "/pages/pageImages/new/tab3.png",
        selectedIconPath: "/pages/pageImages/new/tabSelect3.png",
        text: "党务"
      },
      {
        pagePath: "/pages/my/my",
        iconPath: "/pages/pageImages/new/tab4.png",
        selectedIconPath: "/pages/pageImages/new/tabSelect4.png",
        text: "我的"
      }
    ]
  },
  methods: {
    // tabBar切换事件
    tab_bar_index(e) {
      const url = e.currentTarget.dataset.path
      app.globalData.pageIndex = e.currentTarget.dataset.index * 1
      wx.switchTab({url})
    },

    // 发布添加按钮跳转
    tab_bar_add() {
      var url = "/pages/tab-add/add"
      wx.navigateTo({url})
    },
    onLoad() {
      console.log("global:" + app.globalData.pageIndex)
      this.setData({
        selected: app.globalData.pageIndex
      });
      console.log("selected:" + this.data.selected)
      console.log("list:" + this.data.list)
    }
  }
})